import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: Bars());
  }
}

class Bars extends StatefulWidget {
  const Bars({super.key});

  @override
  State<Bars> createState() => _BarsState();
}

class _BarsState extends State<Bars> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          "Flutter App",
          style: TextStyle(color: Colors.white),
        ),
        backgroundColor: Colors.blue,
      ),
      drawer: Drawer(
        child: Column(
          children: [
            Row(
              children: [
                Expanded(
                  flex: 1,
                  // 内置头部
                  child: UserAccountsDrawerHeader(
                    currentAccountPicture: CircleAvatar(
                      backgroundImage: NetworkImage(
                          "https://www.itying.com/images/flutter/3.png"),
                    ),
                    accountName: Text("张三"),
                    accountEmail: Text("uuu@qq.com"),
                    decoration: BoxDecoration(
                      image: DecorationImage(
                        image: NetworkImage(
                            "https://www.itying.com/images/flutter/4.png"),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                  // 自定义头部
                  // child: DrawerHeader(
                  //   decoration: BoxDecoration(
                  //     // color: Colors.yellow,
                  //     image: DecorationImage(
                  //       image: NetworkImage(
                  //           "https://www.itying.com/images/flutter/4.png"),
                  //       fit: BoxFit.cover,
                  //     ),
                  //   ),
                  //   child: Column(
                  //     children: [
                  //       ListTile(
                  //         leading: CircleAvatar(
                  //           backgroundImage: NetworkImage(
                  //               "https://www.itying.com/images/flutter/4.png"),
                  //         ),
                  //         title: Text(
                  //           "张三",
                  //           style: TextStyle(color: Colors.white),
                  //         ),
                  //       )
                  //     ],
                  //   ),
                  // ),
                )
              ],
            ),
            ListTile(
              leading: CircleAvatar(
                child: Icon(Icons.people),
              ),
              title: Text('个人中心'),
            ),
            Divider(),
            ListTile(
              leading: CircleAvatar(
                child: Icon(Icons.settings),
              ),
              title: Text('系统设置'),
            ),
          ],
        ),
      ),
      endDrawer: Drawer(
        child: Text("右侧侧边栏"),
      ),
      body: Text("ffff"),
    );
  }
}
